<template>
    <div>
        <button @click="$emit('decrement')">-1</button>
        <!-- <input type="text" v-model.lazy="count" @blur="$emit('inputCount', count)"> -->
        <input type="text" v-model.lazy="count">
        <button @click="$emit('increment')">+1</button>
    </div>
</template>

<script setup lang="ts">
import { ref, watch } from 'vue';
const emit = defineEmits(['decrement', 'increment', 'inputCount']);
const count = ref('');

watch(count, () => {
    // 调用父组件的方法，并传值给父组件
    emit('inputCount', count.value);
})


</script>

<style scoped></style>